home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / tcp / amitcp / amitcp-src-22.lha / AmiTCP-2.2 / src / appl / napsaterm / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-07  |  1.5 KB  |  66 lines

  1. RCS_ID_C "$Id: misc.c,v 0.1 1993/03/29 07:49:34 ppessi Exp $";
  2. /* misc.c -- collection of generic useful functions used by niftyterm
  3.  *
  4.  * Copyright 1988, 1989 Chris Newman
  5.  * All Rights Reserved
  6.  * Permission is granted ot copy, modify, and use this as long
  7.  * as this notice remains intact.  This is a nifty program.
  8.  *
  9.  * $Author: ppessi $ $Revision: 0.1 $ $Date: 1993/03/29 07:49:34 $
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <ctype.h>
  14. #include "nifty.h"
  15. #include <devices/timer.h>
  16.  
  17. extern int access(), execve();
  18. extern struct timerequest *tr;
  19.  
  20. /* a string compare which ignores case
  21.  */
  22. #define    TOLOWER(c)  (isupper(c) ? tolower(c) : c)
  23. int lstrncmp(str1, str2, len)
  24.     register char *str1, *str2;
  25.     register int  len;
  26. {
  27.     while (TOLOWER(*str1) == TOLOWER(*str2) && --len)
  28.     str1++, str2++;
  29.     return (TOLOWER(*str1) - TOLOWER(*str2));
  30. }
  31.  
  32. /* This sleeps for a given amount of microseconds
  33.  */
  34. void
  35. udelay(val)
  36. unsigned long val;
  37. {
  38.     tr->tr_time.tv_secs = val / 1000000L;
  39.     tr->tr_time.tv_micro = val % 1000000L;
  40.     tr->tr_node.io_Command = TR_ADDREQUEST;
  41.     DoIO((struct IORequest *)tr);
  42. }
  43.  
  44. /* simple procedure to convert decimal number of 
  45.  * less than 20 digits to a string.
  46.  */
  47. char *itos(i)
  48.     int i;
  49. {
  50.     static char    sbuf[20];
  51.     register char  *pos = sbuf, *rpos = sbuf;
  52.  
  53.     while (i || pos == sbuf) {
  54.     *pos++ = "0123456789"[i % 10];
  55.     i /= 10;
  56.     }
  57.     *pos-- = '\0';
  58.     while (pos > rpos) {
  59.     register char temp = *pos;
  60.     *pos-- = *rpos;
  61.     *rpos++ = temp;
  62.     }
  63.  
  64.     return (sbuf);
  65. }
  66.